import axios from '@/libs/axios.js'
import baseUrl from './index'

let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' }



// 试验任务列表
export const experList = (params) => {
  return axios({
    url: `${baseUrl}/trial-distributed/whitetask/getTaskByStatus/`,
    // url: `${baseUrl}/nsrep-compete/contest/getTaskByStatus/`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}
// 文档列表
export const docList = (params) => {
  return axios({
    //  url: `${baseUrl}/trial/doc/query`,
    url: `${baseUrl}/nsrep-trial-distributed/whitetask/getTaskDocument`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}
// 下载文档
export const downFile = (id, params) => {
  return axios({
    url: `${baseUrl}/trial/doc/download/${id}`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}
// 下载文档
export const sceneList = (params) => {
  return axios({
    url: `${baseUrl}/process/scenarios`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}
// 查询试验是否已绑定工程
export const queryIsBind = (id) => {
  return axios({
    url: `${baseUrl}/topo-edit/tasks/${id}/project`,
    method: 'get',
    headers: jsonHeaders,
  })
}

// 查询场景详情
export const getSceneInfo = (id) => {
  return axios({
    url: `${baseUrl}/process/scenarios/${id}`,
    method: 'get',
    headers: jsonHeaders,
  })
}

// 添加竞赛与黄方系统任务的关系
export const addYellowWhiteRelation = (params) => {
  return axios({
    url: `${baseUrl}/compete/addYellowWhiteRelation`,
    method: 'post',
    data: params,
    headers: jsonHeaders,
  })
}


// 给任务绑定工程
export const bindPro = (params) => {
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/whitetask/taskSetProject`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}


// 解除试验工程绑定
export const unbindPro = (params) => {
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/whitetask/taskUnbindProject`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}

// 查询工程是否存在
export const checkProjectExist = (projectId) => {
  let params = {
    projectId: projectId,
  }
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/whitetask/checkProjectExist`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}

// 白方确认完成
export const prepareConfirm = (params) => {
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/whitetask/action/response`,
    method: 'post',
    params: params,
    headers: jsonHeaders,
  })
}


// 调用黄方的下发操作：创建比赛、工程等
export const buildContest = (taskId) => {
  let api2 = '/api2'
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/task/taskAfterIssusBuildContest/${taskId}`,
   // url: `/api2/task/taskAfterIssusBuildContest/${taskId}`,
    method: `get`,
    headers: jsonHeaders,
  })
}

// 黄方构建综合演练试验团队
export const createComplexExericeTeam = (taskId) => {
  let params = {
    taskId: taskId,
  };
  let api2 = '/api2'
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/schemeComplexExerice/createComplexExericeTeam/`,
   // url: `/api2/schemeComplexExerice/createComplexExericeTeam/`,
    method: 'get',
    params: params,
    headers: jsonHeaders,
  })
}

export const setBuildFlag = (taskId, buildFlag) => {
  let params = {
    taskId: taskId,
    buildFlag: buildFlag,
  };
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/whitetask/setBuildFlag/`,
   // url: `/api2/whitetask/setBuildFlag/`,
    method: 'post',
    params: params,
    headers: jsonHeaders,
  })
}


/**
 * 获取试验详情
 * @param taskId
 */
export const getTaskDetailApi = (taskId) => {
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/task/taskDetail/${taskId}`,
    method: 'get',
    headers: jsonHeaders,
  })
}

/**
 * 校验是否白方准备完成
 * @param taskId 任务id
 * @returns {*}
 */
export const checkWhitePrepareComplete = (taskId) =>{
  let params = {
    taskId: taskId
  };
  return axios({
    url: `${baseUrl}/nsrep-trial-distributed/whitetask/checkWhitePrepareComplete/`,
    method: 'post',
    params: params,
    headers: jsonHeaders,
  })

}
